package com.woniuxy.kaer.shop.consumer;

import com.woniuxy.kaer.shop.service.RefundRequestsService;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class RefundConsumer {
    @Resource
    private RefundRequestsService refundRequestsService;

    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue("wait-exchange"),
                    exchange = @Exchange("refund"),
                    key = "refund_key"
            )
    )
    @RabbitHandler
    public void refund(String refundId)throws Exception {
        refundRequestsService.handleRefund(refundId);
    }
}
